import {Component, OnInit, SimpleChanges} from '@angular/core';
import {MessageService} from '../services/message.service';
import {HttpClient} from '@angular/common/http';
import {GetInfoService} from '../services/get-info.service';
import {AppComponent} from '../app.component';
@Component({
  selector: 'app-shop-car',
  templateUrl: './shop-car.component.html',
  styleUrls: ['./shop-car.component.css']
})
export class ShopCarComponent implements OnInit {
  dataSo: Array<Obj>;
  isstart: false;
  // 商品总价
  aszon: 0;
  constructor(private msg: MessageService, private getInfo: GetInfoService, private http: HttpClient, private app: AppComponent) { }

  ngOnInit() {
    this.getInfo.getcarts((data) => {
      this.dataSo = this.app.carts = data;
    });
  }
  doClick(e) {
    console.log(e.target.parentElement.parentElement.parentElement);
  }
  dodelete (ol) {
    this.app.deDeletion(ol);
    this.http.post('/apl/delete', {
      img: ol.img,
      title: ol.title,
      gui: ol.gui,
      num: ol.num,
      price: ol.price,
      total: ol.total
    }).subscribe((data) => {
      console.log(data);
    });
  }
  doprice () {
    return this.app.getTotalPrice();
  }
  // 加号
  doCJia (e) {
    this.app.doClickJ(e);
  }
  // 减号
  doCHao (e) {
    this.app.doClickH(e);
  }
  // 点击全选
  doClikbool () {
    // this.isstart = !this.isstart;
  }
}
export interface Obj {
  img: string;
  title: string;
  gui: string;
  num: number;
  price: number;
  total: number;
}
